<?php
namespace app\index\controller;
use think\Db;
use think\Config;
class My extends Base
{
    public function index()
    {
        $user = $this->getUserInfo();
        Db::table('up_active')
            ->where('active_end_time','<=',date('Y-m-d H:i:s'))
            ->where('active_status',1)
            ->setField('active_status',2);
        Db::table('up_active')
            ->where('active_end_time','>=',date('Y-m-d H:i:s'))
            ->where('active_status',2)
            ->setField('active_status',1);
        //

        $data = Db::table('up_active_member')->alias('am')
            ->join('up_active a','am.am_active_id=a.active_id','LEFT')
            ->where('am_user_id',$user['user_id'])
            ->where('active_id','>',0)
            ->order('am_user_status asc,active_start_time desc')
            ->page(1,10)
            ->select();
        $this->assign('list',$data);
        return $this->fetch();
    }
    /***
     * @return \think\response\Json
     * ajax请求
     */
    public function ajaxactivitylist(){
        extract(input());
        $user = $this->getUserInfo();
        $data = Db::table('up_active_member')->alias('am')
            ->join('up_active a','am.am_active_id=a.active_id','LEFT')
            ->where('am_user_id',$user['user_id'])
            ->where('active_id','>',0)
            ->order('am_user_status asc,active_start_time desc')
            ->page($page,10)
            ->select();
        return json(['status'=>200,'msg'=>$data]);
    }
}
